<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8"/>
        <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
        <meta http-equiv="X-UA-Compatible" content="ie=edge"/>
        <title>Document</title>
        <script>
            /* 
                问题  输入年、月、日，计算某一天是该年的第几天（周）
             */
            var year = 2008;
            var month = 12;
            var date = 8;
            var sum = 0; //记录总天数
            switch(month){
                case 12:
                    sum += 30;
                case 11:
                     sum += 31;
                case 10:
                    sum += 30;
                case 9:
                    sum += 31;
                case 8:
                    sum += 31;
                case 7:
                    sum += 30;
                case 6:
                    sum += 31;
                case 5:
                    sum += 30;
                case 4:
                    sum += 31;
                case 3:
                    sum += 28;
                    if(year % 4 == 0 && year % 100 != 0 || year % 400 == 0){
                        sum += 1;
                    }
                case 2:
                    sum += 31;
                case 1:
                    sum += date;
                    break;
                default:
                    alert("error");
                    break;
            }

            alert("这是第" + sum + "天");

            /* 
                Math.ceil() 向上取整
             */
            // alert(Math.ceil(3));

            // var week = parseInt(sum / 7) + 1;
            var week = Math.ceil(sum / 7);
            alert("这是第" + week + "周");

        </script>
    </head>
    <body>
        
    </body>
</html>